package com.big.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.big.app.dao.ContentDao;
import com.big.app.entity.Content;
import com.big.app.service.intf.ContentService;
import com.big.app.vo.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @author: zjl
 * @description
 * @date: 2022/4/22 18:48
 */
@Service
public class ContentServiceImpl implements ContentService {
    @Resource
    private ContentDao contentDao;
    @Override
    public R All(Integer mid) {
        if (contentDao.selectList(new QueryWrapper<Content>().eq("mid",mid))!=null){
            return new R(200,"ok",contentDao.selectList(new QueryWrapper<Content>().eq("mid",mid)));
        }
        return new R(400,"fail",null);
    }

    @Override
    public R insert(String content, Integer mid) {
        Content content1 = new Content();
        content1.setContent(content);
        content1.setMid(mid);
        content1.setUsername("用户155139617353");
        content1.setCtime(new Date());
        content1.setImg("https://img0.baidu.com/it/u=4002049441,3260030671&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500");
        if (contentDao.insert(content1)>0){
            return new R(200,"ok",null);
        }
        return new R(400,"fail",null);
    }
}
